﻿package Naruto{
	import flash.display.*;
	
	public class Genin extends Sprite{
		private var _stage : Stage = null;
		private var _aGenin:AGenin = new AGenin();
		private var aiAttack:Attack;
		private var posarr:Array;
		private var aiStatus:int = 1; //初始化为活着。0:死了。1:活着
		
		public function Genin(stage : Stage){
			this._stage = stage;
			init();
		}
		
		public function init():void{
			
			//存放备选坐标
			posarr = new Array(new Array(285,40),
							   new Array(260,505),
							   new Array(242,232),
							   new Array(333,77),
							   new Array(346,204),
							   new Array(375,412),
							   new Array(465,65),
							   new Array(465,740),
							   new Array(645,75),
							   new Array(655,530)
							   );
			var temp = choosepos();		//数组第几个坐标2元组
			setpos(temp);
			aiAttack = new Attack();			
		}
		
		public function choosepos():int{
			var temp;
			while(1){
				if( (temp = Math.round(Math.random()*10)) <= 9 ){
					break;
				}
			}
			return temp;
		}

		public function setpos(temp:Number){
			this._aGenin.x = posarr[temp][0];
			this._aGenin.y = posarr[temp][1];
		}		
		
		public function getme(){
			this._aGenin.gotoAndStop("start");
			return this._aGenin;
		}
		
		public function getAttack(){
			return this.aiAttack;
		}
		
		public function getStatus(){
			return this.aiStatus;
		}
		
		public function setStatus(newStatus:int){
			this.aiStatus = newStatus;
		}
/*
		public function getposx(){
			return this._aGenin.x;
		}
		public function getposy(){
			return this._aGenin.y;
		}
*/		

		public function removeGenin():void{	//删除舞台下忍
			if (this._stage.contains(this._aGenin)) {
				this._stage.removeChild(this._aGenin);
			}
		}

	}
}